using System;
using System.Collections.Generic;
using System.Text;
using System.Data.Common;
using System.Data;
using XBLib.Dal.AdoDal;
using DataInfo;
using KenLib.Common;
namespace KenLib.Dal
{
    public class 賞罰情報Dao : BaseAdoDao
      {
          private string m_requestTime;
          private string m_displayTime;
          public int Insert(賞罰情報 obj)
          {
              int i = 0;
              try
              {
                  m_requestTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  DbParameter param20 = _daoHelper.CreateParameter("@廃止区分", obj.廃止区分, DbType.Int16);
                  DbParameter param1 = _daoHelper.CreateParameter("@賞罰名", obj.賞罰名, DbType.String);
                  DbParameter param2 = _daoHelper.CreateParameter("@賞罰年月日", obj.賞罰年月日, DbType.DateTime);
                  DbParameter param3 = _daoHelper.CreateParameter("@賞罰特記事項", obj.賞罰特記事項, DbType.String);
                  DbParameter param4 = _daoHelper.CreateParameter("@社員ID", obj.社員ID, DbType.Int32);
                  DbCommand command = _daoHelper.CreateCommand(CommandNameManager.Insert_HumanRewPunInfo, CommandType.StoredProcedure, param20, param1, param2, param3, param4);
                  i = _daoHelper.Execute(command);
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteLog("", "", "INSERT", "Insert_HumanRewPunInfo", m_requestTime, m_displayTime);
              }
              catch (Exception ex)
              {
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteErr("", "", "SELECT", ex.Message, m_requestTime, m_displayTime);
              }
              return i;
          }

          public int Update(賞罰情報 obj)
          {
              int i = 0;
              try
              {
                  m_requestTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  DbParameter param20 = _daoHelper.CreateParameter("@廃止区分", obj.廃止区分, DbType.Int16);
                  DbParameter param0 = _daoHelper.CreateParameter("@ID", obj.ID, DbType.Int32);
                  DbParameter param1 = _daoHelper.CreateParameter("@賞罰名", obj.賞罰名, DbType.String);
                  DbParameter param2 = _daoHelper.CreateParameter("@賞罰年月日", obj.賞罰年月日, DbType.DateTime);
                  DbParameter param3 = _daoHelper.CreateParameter("@賞罰特記事項", obj.賞罰特記事項, DbType.String);
                  DbParameter param4 = _daoHelper.CreateParameter("@社員ID", obj.社員ID, DbType.Int32);
                  DbCommand command = _daoHelper.CreateCommand(CommandNameManager.Update_HumanRewPunInfo, CommandType.StoredProcedure,param20, param0, param1, param2, param3, param4);
                  i = _daoHelper.Execute(command);
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteLog("", "", "UPDATE", "Update_HumanRewPunInfo", m_requestTime, m_displayTime);
              }
              catch (Exception ex)
              {
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteErr("", "", "SELECT", ex.Message, m_requestTime, m_displayTime);
              }
              return i;
          }

          public int Delete(int id)
          {
              int i = 0;
              try
              {
                  m_requestTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  DbParameter param0 = _daoHelper.CreateParameter("@ID", id, DbType.Int32);

                  DbCommand command = _daoHelper.CreateCommand(CommandNameManager.Delete_HumanRewPunInfo, CommandType.StoredProcedure, param0);
                  i = _daoHelper.Execute(command);
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteLog("", "", "DELETE", "Delete_HumanRewPunInfo", m_requestTime, m_displayTime);
              }
              catch (Exception ex)
              {
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteErr("", "", "SELECT", ex.Message, m_requestTime, m_displayTime);
              }
              return i;
          }

        public int InsertPartial(賞罰情報 obj)
        {
            int i = 0;
            try
            {
                m_requestTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                DbParameter param20 = _daoHelper.CreateParameter("@廃止区分", obj.廃止区分, DbType.Int16);
                DbParameter param1 = _daoHelper.CreateParameter("@賞罰名", obj.賞罰名, DbType.String);
                DbParameter param2 = _daoHelper.CreateParameter("@賞罰年月日", obj.賞罰年月日, DbType.DateTime);
                DbParameter param3 = _daoHelper.CreateParameter("@賞罰特記事項", obj.賞罰特記事項, DbType.String);
                DbParameter param4 = _daoHelper.CreateParameter("@社員ID", obj.社員ID, DbType.Int32);
                DbCommand command = _daoHelper.CreateCommand(CommandNameManager.sp_Insert賞罰情報_Partial, CommandType.StoredProcedure, param20, param1, param2, param3, param4);
                i = _daoHelper.Execute(command);
                m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                ExportFile.WriteLog("", "", "INSERT", "sp_Insert賞罰情報_Partial", m_requestTime, m_displayTime);
            }
            catch (Exception ex)
            {
                m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                ExportFile.WriteErr("", "", "INSERT", ex.Message, m_requestTime, m_displayTime);
            }
            return i;
        }
        #region Mai
        public DataTable    ShowGrid賞罰情報(int 社員ID)
        {
            DbParameter param = _daoHelper.CreateParameter("@社員ID", 社員ID, DbType.Int32);
            DbCommand dbcommand = _daoHelper.CreateCommand("sp_frmJ_TraineeRewPunInput_ShowGrid賞罰情報_Mai", CommandType.StoredProcedure, param);
            return _daoHelper.Query(dbcommand);
        }
        public void Insert_frmJ_TraineeRewPunInput(賞罰情報 obj)
        {
            DbParameter param0 = _daoHelper.CreateParameter("@賞罰名", obj.賞罰名, DbType.String);
            DbParameter param1 = _daoHelper.CreateParameter("@賞罰年月日", obj.賞罰年月日, DbType.DateTime);
            DbParameter param2 = _daoHelper.CreateParameter("@賞罰特記事項", obj.賞罰特記事項, DbType.String);
            DbParameter param3 = _daoHelper.CreateParameter("@廃止区分", obj.廃止区分, DbType.Int16);
            DbParameter param4 = _daoHelper.CreateParameter("@社員ID", obj.社員ID, DbType.Int32);
            DbCommand dbcommand = _daoHelper.CreateCommand("sp_frmJ_TraineeRewPunInput_Insert賞罰情報_Mai", CommandType.StoredProcedure, param0, param1, param2, param3, param4);
            _daoHelper.Execute(dbcommand);
        }
        public void Update_frmJ_TraineeRewPunInput(賞罰情報 oj)
        {
            DbParameter param = _daoHelper.CreateParameter("@賞罰名", oj.賞罰名, DbType.String);
            DbParameter param1 = _daoHelper.CreateParameter("@賞罰年月日", oj.賞罰年月日, DbType.DateTime);
            DbParameter param2 = _daoHelper.CreateParameter("@賞罰特記事項", oj.賞罰特記事項, DbType.String);
            DbParameter param3 = _daoHelper.CreateParameter("@ID", oj.ID, DbType.Int32);
            DbCommand dbcommand = _daoHelper.CreateCommand("sp_frmJ_TraineeRewPunInput_Update賞罰情報_Mai", CommandType.StoredProcedure, param, param1, param2, param3);
            _daoHelper.Query(dbcommand);
        }
        #endregion
        #region TUNG

        public DataTable Select_frmJ_StaffRewPunInput(int ID)
        {
            DbParameter param1 = _daoHelper.CreateParameter("@ID", ID, DbType.Int32);
            DbCommand dbcommand = _daoHelper.CreateCommand("sp_Select_frmJ_StaffRewPunInput_TUNG", CommandType.StoredProcedure, param1);
            return _daoHelper.Query(dbcommand);
        }
          
        #endregion

      }
}
